<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>匹配车与司机</title>
<style type="text/css">
	div,table{
		width: 80%;
	}
	table{
		border-collapse: collapse;
		border: 1px solid #ccc;
		text-align: center;
	}
	.table td{
		border: 1px solid #ccc;
	}
	.first{
		margin-top: 2%;
	}
</style>
</head>
<body>
<center>

<form action="${pageContext.request.contextPath }/company/createTwoOrder.do" name="sc" method="post">
	<div class="first">
		<table>
			<tr>
				<th><a href="${pageContext.request.contextPath }/company/queryTruckAndTruckStatus.do">查看所有车辆</a></th>
				<th><a href="${pageContext.request.contextPath }/company/lastOrderlist.do">查看市内运输订单</a></th>
			</tr>
		</table>
		<table class="table">
				<tr>
					<td><input id="all" type="checkbox" value="全选"></td>
					<td>序号</td>
					<td>总提单号</td>
					<td>分单号</td>
					<td>pdf地址</td>
					<td>送达地址</td>
					<td>毛重</td>
					<td>件数</td>
				</tr>
				<c:if test="${empty cargolist }">
				<tr>
					<td colspan="8">暂时没有数据</td>
				</tr>
				</c:if>
				<c:if test="${not empty cargolist }">
				<c:forEach var="cl" items="${cargolist }" varStatus="vs">
				<tr>
					<td><input name="box" type="checkbox" value="${cl.cargoId }"></td>
					<td>${vs.count }</td>
					<td>${cl.totalOrderNu }</td>
					<td>${cl.pointOrderNu }</td>
					<td><a href="${cl.uploadPdf }">点击下载</a></td>
					<td>${cl.detailed }</td>
					<td>${cl.heavy }</td>
					<td>${cl.count }</td>
				</tr>
				</c:forEach>
				</c:if>
		</table>
	</div>
	<div>
		<table class="table">
				<caption>匹配车辆与司机</caption>
				<tr>
					<td>分配车辆</td>
					<td>
						<select name="truckId">
							<option value="">--请选择车辆--</option>
<c:forEach var="tl" items="${trucklist }">
							<option value="${tl.truckId }">车牌:${tl.plateNu }/白卡号:${tl.cardNu }/吨位:${tl.loadHeavy }/所在位置:${tl.address }</option>
</c:forEach>
						</select>
					</td>
					<td>分配司机</td>
					<td>
						<select name="userId">
							<option value="">--请选择司机--</option>
<c:forEach var="ul" items="${userlist }">
							<option value="${ul.userId }">姓名:${ul.userName }/电话:${ul.userPhone }/所在位置:${tl.address }</option>
</c:forEach>
						</select>
					</td>
				</tr>
		</table>
	</div>
	 <input type="hidden" id="scId" name="values">
 </form>
	<input type="button" onclick="add()" value="提交" />
</center>
</body>
<!-- 批量删除 -->
<script type="text/javascript">
	function add() {
	  var ck_value = "";
	  var obj = document.getElementsByName("box"); 
	  var objarray = obj.length; 
	
	   for (var i=0; i<objarray; i++ ){
	     if(obj[i].checked == true){ //判断复选框是否选中
	       ck_value += obj[i].value + ","; //值的拼凑 .. 具体处理看你的需要,
	      }
	   }
 
	 //去掉最后一个逗号
	  var lastIndex = ck_value.lastIndexOf(',');
      if (lastIndex > -1) {
          ck_value = ck_value.substring(0, lastIndex) + ck_value.substring(lastIndex + 1, ck_value.length);
      }
      if(window.confirm("确定提交吗!")) {
        //alert(ck_value);//输出你选中的那些复选框的值
        document.getElementById("scId").value = ck_value;
              sc.submit();  //提交id为name的form表单
        }
  }
</script>
</html>